﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPC.Communication.Profinet.Melsec
{
    public class MelsecA1EDataType
    {
        public static readonly MelsecA1EDataType X = new MelsecA1EDataType(new byte[2]
	{
		88,
		32
	}, 1, "X*", 16);

        public static readonly MelsecA1EDataType Y = new MelsecA1EDataType(new byte[2]
	{
		89,
		32
	}, 1, "Y*", 16);

        public static readonly MelsecA1EDataType M = new MelsecA1EDataType(new byte[2]
	{
		77,
		32
	}, 1, "M*", 10);

        public static readonly MelsecA1EDataType S = new MelsecA1EDataType(new byte[2]
	{
		83,
		32
	}, 1, "S*", 10);

        public static readonly MelsecA1EDataType F = new MelsecA1EDataType(new byte[2]
	{
		70,
		32
	}, 1, "F*", 10);

        public static readonly MelsecA1EDataType B = new MelsecA1EDataType(new byte[2]
	{
		66,
		32
	}, 1, "B*", 16);

        public static readonly MelsecA1EDataType TS = new MelsecA1EDataType(new byte[2]
	{
		84,
		83
	}, 1, "TS", 10);

        public static readonly MelsecA1EDataType TC = new MelsecA1EDataType(new byte[2]
	{
		84,
		67
	}, 1, "TC", 10);

        public static readonly MelsecA1EDataType TN = new MelsecA1EDataType(new byte[2]
	{
		84,
		78
	}, 0, "TN", 10);

        public static readonly MelsecA1EDataType CS = new MelsecA1EDataType(new byte[2]
	{
		67,
		83
	}, 1, "CS", 10);

        public static readonly MelsecA1EDataType CC = new MelsecA1EDataType(new byte[2]
	{
		67,
		67
	}, 1, "CC", 10);

        public static readonly MelsecA1EDataType CN = new MelsecA1EDataType(new byte[2]
	{
		67,
		78
	}, 0, "CN", 10);

        public static readonly MelsecA1EDataType D = new MelsecA1EDataType(new byte[2]
	{
		68,
		32
	}, 0, "D*", 10);

        public static readonly MelsecA1EDataType W = new MelsecA1EDataType(new byte[2]
	{
		87,
		32
	}, 0, "W*", 16);

        public static readonly MelsecA1EDataType R = new MelsecA1EDataType(new byte[2]
	{
		82,
		32
	}, 0, "R*", 10);

        private byte[] _dataCode = new byte[2];
        private byte _dataType = 0;
        public byte[] DataCode
        {
            get { return _dataCode; }
            private set { _dataCode = value; }
        }


        public byte DataType
        {
            get { return _dataType; }
            private set { _dataType = value; }
        }


        public string AsciiCode
        {
            get;
            private set;
        }

        public int FromBase
        {
            get;
            private set;
        }

        public MelsecA1EDataType(byte[] code, byte type, string asciiCode, int fromBase)
        {
            DataCode = code;
            AsciiCode = asciiCode;
            FromBase = fromBase;
            if (type < 2)
            {
                DataType = type;
            }
        }
    }
}
